﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$makhoa = $_POST["txtMAK"];
$tenkhoa = $_POST["txtTenK"];
$mk = $_POST["txtMK1"];
$mkmh = md5($mk);

// Kiem tra ma khoa co bi trung hay khong
$queryMAK = "select MA_KHOA from khoa where MA_KHOA = '$makhoa'";
$resultMAK = mysql_query($queryMAK, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMAK);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=addcnk&info=dupmak");
}
else
{
	// Them khoa
	$queryInsCNK = "insert into khoa(MA_KHOA, TEN_KHOA, MAT_KHAU) values ('$makhoa', '$tenkhoa', '$mkmh')";
	mysql_query($queryInsCNK, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=addcnksucc");
}

?>